//
//  ViewController.m
//  MGYRightAndError
//
//  Created by jiangjunwy on 16/7/13.
//  Copyright © 2016年 SanYouApp. All rights reserved.
//

#import "ViewController.h"
#import "MGYAlertView.h"


@interface ViewController (){
    MGYAlertView * _animationView;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    _animationView = [[MGYAlertView alloc] initWithFrame:CGRectMake(0, 150, self.view.bounds.size.width, 120)];
    [self.view addSubview:_animationView];
    
    
    
    UIButton *startButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    startButton.frame = CGRectMake(10, 300, 100, 50);
    [startButton addTarget:self action:@selector(startAnimation:) forControlEvents:UIControlEventTouchUpInside];
    [startButton setTitle:@"加载成功" forState:UIControlStateNormal];
    [self.view addSubview:startButton];
    
    UIButton *stopButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    stopButton.frame = CGRectMake(110, 300, 100, 50);
    [stopButton addTarget:self action:@selector(stopAnimation:) forControlEvents:UIControlEventTouchUpInside];
    [stopButton setTitle:@"加载失败" forState:UIControlStateNormal];
    [self.view addSubview:stopButton];
    
    UIButton *resumeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    resumeButton.frame = CGRectMake(210, 300, 100, 50);
    [resumeButton addTarget:self action:@selector(resumeAnimation:) forControlEvents:UIControlEventTouchUpInside];
    [resumeButton setTitle:@"loading。。。" forState:UIControlStateNormal];
    [self.view addSubview:resumeButton];
}


-(void)startAnimation:(UIButton *)sender
{
//    [_animationView startAnimation1];
    [MGYAlertView MGYSuccessWithText:@"success"];
    
}


-(void)stopAnimation:(UIButton *)sender
{
    [MGYAlertView MGYfailureWithText:@"error"];
}

-(void)resumeAnimation:(UIButton *)sender
{
    
    [MGYAlertView MGYShowLoadingWithText:@"loading"];
    [self performSelector:@selector(aaaaa) withObject:nil afterDelay:5.0f];
//     [self performSelector:@selector(bbbbb) withObject:nil afterDelay:5.0f];
}



-(void)aaaaa{
     [MGYAlertView MGYSuccessWithText:@"success"];
   
}

-(void)bbbbb{
    [MGYAlertView MGYfailureWithText:@"error"];
}

-(void)ccccc{
    [MGYAlertView MGYShowLoadingWithText:@"loading"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
